import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    proxy: {
      '/api': {
        // target: 'http://222.71.114.106:85/api',
        target: 'http://47.121.194.81:85/api',
        // target: 'http://222.71.114.106:88/api',
        // target:'http://218.201.57.62/api',
        // target: 'http://192.168.1.67:18008/api',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  plugins: [
    vue(),
    AutoImport({
      imports: [
        'vue',
        'vue-router',
        'pinia',
        {
          '@arco-design/web-vue':[
            'Message',
            'Modal',
            'Notification'
          ],
          'lodash':[
            'cloneDeep',
            'throttle',
            'debounce'
          ]
        }
      ],
      dirs:['src/hooks','src/api','src/store','src/locales'],
      dts:'src/auto-import.d.ts'
    }),
    Components({
      dirs:['src/components']
    }),
  ],
  resolve: {
    alias: {
      // 路径重写
      "@": resolve('src'),
    },
    // 可省略的后缀
    extensions: ['.js', '.json', '.ts', '.mjs']
  },
  // 打包使用相对路径
  base: './'
})

